package com.lap.auth.application.dict.assembler;

import com.lap.auth.application.dict.command.BatchCreateDictCmd;
import com.lap.auth.application.dict.command.CreateDictCmd;
import com.lap.auth.application.dict.dto.DictDto;
import com.lap.auth.domain.dict.Dict;
import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(componentModel = "spring")
public interface DictAssembler {

  @Mapping(target = "id", ignore = true)
  Dict toDomain(String dictTypeCode, CreateDictCmd cmd);

  default List<Dict> toDomains(BatchCreateDictCmd cmd) {
    return cmd.getList().stream().map(item -> toDomain(cmd.getDictTypeCode(), item)).toList();
  }

  DictDto toDto(Dict dict);

  List<DictDto> toDtoList(List<Dict> list);
}
